<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.NewsComment"%>
<%@page import="com.wanmait.hotelManage.vo.NewsCommentReport"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<NewsCommentReport>NewsCommentReports=(List<NewsCommentReport>)request.getAttribute("NewsCommentReports");
    List<NewsComment>NewsComments=(List<NewsComment>)request.getAttribute("newsComments");
    %>
<jsp:include page="/manage/inc/header.jsp"></jsp:include>
   <jsp:include page="/manage/inc/menu.jsp"></jsp:include>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">新闻评论举报管理</span></div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量打回</a>
                        <a id="batchUp" href="javascript:void(0)"><i class="icon-font"></i>批量通过</a>
                         <span id="roomtypeid">
                    举报人：<input type="text" size="5" id="textid">
                     <input class="btn btn-primary btn6 mr10" id="roomtype" value="搜索" type="button"><span id="spanroomtype"></span>
                     </span>
                    </div>
                </div>
                <div class="result-content">
                <div id="pagerdiv">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                             <th>序号</th>
                            <th>ID</th>
                            <th>举报人</th>
                            <th>举报内容</th>
                            <th>举报原因</th>
                            <th>被举报人</th>
                            <th>举报时间</th>
                            <th>审核</th>
                        </tr>
                        <%
                        if(NewsCommentReports!=null&&NewsComments!=null){
                        	for(int i=0;i<NewsCommentReports.size();i++){
                        		NewsCommentReport newsCommentReport=NewsCommentReports.get(i);
                        		NewsComment newsComment=NewsComments.get(i);
                        		DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        		String inputTime=df.format(newsCommentReport.getInputTime());
                        		%>
                        		 <tr id="tr<%=newsCommentReport.getId()%>">
                            <td class="tc"><input class="choose" id="id<%=newsComment.getId() %>" data-id=<%=newsCommentReport.getId() %> name="id[]" value="59" type="checkbox"></td>
                            <td><%=i+1 %></td>
                            <td><%=newsCommentReport.getId() %></td>
                            <td><%=newsCommentReport.getUserinfo().getUsername() %></td>
                            <td style="width:500px;height:100px"><%=newsComment.getContent() %></td>
                            <td><%=newsCommentReport.getReason() %></td>
                            <td><%=newsComment.getUserinfo().getUsername() %></td>
                            <td><%=inputTime %></td>
                            <td>
                                <a class="link-update" href="<%=path%>/manage/NewsCommentReportServlet?action=by&id=<%=newsCommentReport.getId()%>&id1=<%=newsComment.getId()%>">通过</a>
                                <a class="link-del" id="de<%=newsCommentReport.getId() %>" href="javaScript:void(0)">打回</a>
                            </td>
                        </tr>
                        		<%
                        	}
                        }
                        %>
                    </table>
                    
                    <div class="qwe">
                     <%
                     Pager pager=(Pager)request.getAttribute("pager");
                     if(pager!=null){
                     	 int start= 1;
                          int end =pager.getPageCount();
                          if(pager.getPageCount()>5){
                         	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                         	 end=start+4;
                         	 if(end>pager.getPageCount()){
                         		 end=pager.getPageCount();
                         		 start=end-4;
                         	 }
                          }
                          %>
                          [<a class="ok" href="javascript:void(0)">上一页</a>]
                          <%
                     	for(int i=start;i<=end;i++){
                     		%>
                     		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                     		<%
                     	}
                          %>
                          [<a class="no" href="javascript:void(0)">下一页</a>]
                          <%
                     }
                     %>
                    </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer.jsp"></jsp:include>
<style>
.qwe{
text-align:center;
}
</style>
<script>
$(function(){
	$("#pagerdiv").on("click",".link-del",function(){
		if(!window.confirm("确定未通过吗")){
			return false;
		}
		var id=$(this).attr("id").substring(2);
			$.ajax({
				url:"<%=path%>/manage/NewsCommentReportServlet?action=updateNoby",
				data:{id:id},
				success:function(){
					$("#tr"+id).remove();
				}
			})
	})
	$("#pagerdiv").on("click",".allChoose",function(){
		$(".choose").prop("checked",$(this).prop("checked"));
	})
	$("#batchDel").click(function(){
		var arr=[];
		$(".choose:checked").each(function(){
			var id=$(this).data("id");
			arr.push(id);
		})
		if(arr.length>0){
			$.ajax({
				url:"<%=path%>/manage/NewsCommentReportServlet?action=updaedel",
				data:{ids:arr.toString()},
				success:function(){
					for(var i=0;i<arr.length;i++){
						$("#tr"+arr[i]).remove();
					}
				}
			})
		}
	})
	$("#batchUp").click(function(){
		var arr=[];
		$(".choose:checked").each(function(){
			var id=$(this).data("id");
			arr.push(id);
		})
		if(arr.length>0){
			$.ajax({
				url:"<%=path%>/manage/NewsCommentReportServlet?action=bys",
				data:{ids:arr.toString()},
				success:function(){
					for(var i=0;i<arr.length;i++){
						$("#tr"+arr[i]).remove();
					}
				}
			})
		}
	})
	$(".no").click(function(){
							/* $(".number").css("color","black");
							$(this).css("color","red"); */
							var cont=<%=pager.getPageNo()%>;
							if(cont<<%=pager.getPageCount()%>){
								cont++;
							}
							$.ajax({
								url:"<%=path%>/manage/NewsCommentReportServlet?action=initTwo",
									data:{id:cont},
										success:function(msg){
											$("#pagerdiv").html(msg);
										}
							})
						})
	$(".ok").click(function(){
		/* $(".number").css("color","black");
		$(this).css("color","red"); */
		var cont=<%=pager.getPageNo()%>;
		if(cont>1){
			cont--;
		}
		$.ajax({
			url:"<%=path%>/manage/NewsCommentReportServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$("#pagerdiv").html(msg);
					}
		})
	})
	$(".number").click(function(){
		var cont=$(this).html();
		$.ajax({
			url:"<%=path%>/manage/NewsCommentReportServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$("#pagerdiv").html(msg);
					}
		})
	})
	$("#roomtype").click(function(){
		var text=$("#textid").val();
		if(text.length==0){
			$("#spanroomtype").html("不能为空");
			return false;
		}else{
			$("#spanroomtype").html(" ");
			$.ajax({
				url:"<%=path%>/manage/NewsCommentReportServlet?action=search",
					data:{text:text},
						success:function(msg){
							$("#pagerdiv").html(msg);
						}
			})
		}
	})
})
</script>
<style>
.qwe{
text-align:center;
}
#roomtypeid{
margin-left:100px;
}
</style>